package es.ats.codington.festival.junit.daos;

import static org.junit.Assert.*;

import java.sql.Connection;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.ats.codington.festival.daos.EventDAOImp;
import es.ats.codington.festival.daos.VisitorDAOImp;
import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.domain.Museum;
import es.ats.codington.festival.domain.Visitor;
import es.ats.codington.festival.utils.FERSDataConnection;

public class tVisitorDAOImp extends TestCase{

	Visitor visitor;
	VisitorDAOImp visitorDAO;
	Connection con;
	
	@Before
	protected void setUp() throws Exception {
		super.setUp();
		visitor = new Visitor("Luis","Lopez","Burundanga","juan@hotmail.com","7574735-H","666555444","Calle Melancolia","****",false);
		visitorDAO = new VisitorDAOImp();
		con = FERSDataConnection.getConnection();
		VisitorDAOImp visitorDAO = new VisitorDAOImp();
	}
			
	@After
	protected void tearDown() throws Exception {
		super.tearDown();
		con.close();
	}
	
	@Test
	public void testInsertVisitor(){
		int nRow = 0;
		nRow = visitorDAO.insertVisitor(visitor,con);
		assertEquals(1,nRow);
	}
	@Test
	public void testUpdateVisitor(){
		int nRow = 0;
		visitor.setnPhone("666999666");
		nRow = visitorDAO.updateVisitor(visitor, visitor.getUserName(),con);
		assertEquals(1,nRow);
	}
	@Test
	public void testLogin(){
		int nRow = 0;
		nRow = visitorDAO.loginDAO(visitor,con);
		assertEquals(1,nRow);
	}
	@Test
	public void testDeleteVisitor(){
		int nRow = 0;
		nRow = visitorDAO.deleteVisitor(visitor.getUserName(),con);
		assertEquals(1,nRow);
	}
}
